package com.example.baseproject.login;


import android.content.Intent;
import android.view.View;

import androidx.activity.result.ActivityResult;
import androidx.activity.result.ActivityResultCallback;
import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;

import com.blankj.utilcode.util.LogUtils;
import com.example.baseproject.R;
import com.example.baseproject.databinding.FragmentTestBinding;
import com.example.baseproject.easyhttptest.TestViewModel;
import com.tjcd.project.library_base.base.fragment.BaseNetFragment;

public class TestFragment extends BaseNetFragment<FragmentTestBinding> {
    /**
     * 通用的Contract,不做任何转换，Intent作为输入，ActivityResult作为输出，这也是最常用的一个协定
     */
    ActivityResultLauncher<Intent> mStartActivityForResult = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), new ActivityResultCallback<ActivityResult>() {
        @Override
        public void onActivityResult(ActivityResult result) {
            if (null == result.getData()){
                LogUtils.e("asd = 空data");
                return;
            }
            LogUtils.e("asd = " + result.getData().getStringExtra("key"));
        }
    });

    @Override
    protected Class setViewModelClass() {
        return TestViewModel.class;
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.fragment_test;
    }

    @Override
    protected void init() {
        vBinding.tempTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                vBinding.tempTv.setText("测试测试测试测试");
            }
        });
    }

    @Override
    protected void onLazyLoad() {

    }
}